<template>
  <div>
    <h2>我是自定义指令</h2>
    <input type="text" name="" v-autofocus />
  </div>
</template>

<script>
export default {
  // 局部注册指令
  directives: {
    autofocus: {
      mounted(el,binding,vNode,preNode) {
        el.focus();
      },
    },
  },
};
</script>

<style></style>
